<?php
$names = array('Andrew',
                'John',
                'Peter',
                'Nastin',
                'Bill');
$output = preg_grep('/^[a-m]/i', $names);
print_r($output);